package com.qcxk.yuqian.system.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qcxk.yuqian.system.entity.Organ;
import com.qcxk.yuqian.system.mapper.OrganMapper;
import com.qcxk.yuqian.system.mapper.RoleAuthMapper;
import com.qcxk.yuqian.system.mapper.UserRoleMapper;
import com.qcxk.yuqian.system.service.OrganService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrganServiceImp extends ServiceImpl<OrganMapper, Organ> implements OrganService {

    @Autowired
    private OrganMapper organMapper;
    @Autowired
    private UserRoleMapper userRoleMapper;
    @Autowired
    private RoleAuthMapper roleAuthMapper;


    @Override
    public Page queryOrganList(Page page, Organ organ) {
        QueryWrapper<Organ> organQueryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(organ.getName())) {
            organQueryWrapper.like("name", organ.getName());
        }
        if (StringUtils.isNotBlank(organ.getCode())) {
            organQueryWrapper.like("code", organ.getCode());
        }
        organMapper.selectPage(page, organQueryWrapper);
        return page;
    }

    @Override
    public int updateOrgan(Organ organ) {
        return organMapper.updateById(organ);
    }

    @Override
    public boolean removeRole(Integer id) {
        return false;
    }

    @Override
    public boolean grantAuthToRole(Integer roleId, Integer[] idarr) {
        return false;
    }

    @Override
    public boolean grantRoleForUser(Integer userId, Integer roleId) {
        return false;
    }
}
